<!DOCTYPE html>
<html lang="cn-ZH">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>山东省足球运动协会</title>
    <!--[if lt IE 9]>
         
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
         
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    <link rel="stylesheet" href="./css/bootstrap.min.css">
    <link rel="stylesheet" href="./css/main.css">
</head>
<style>
    .test p {
        font-weight: 700;
        font-size: 24px;
        text-align: center;
    }

    .test.container {
        width: 1178px;
        min-width: 1178px;
        padding: 0;
        text-align: center;
        padding-top: 30px;
        margin-bottom: 155px;
        background: #fff;
        background-image: linear-gradient(#fff 13px, transparent 0), linear-gradient(90deg, #E9EBED 2px, transparent 0);
        background-size: 15px 15px, 15px 15px;
    }

    .test .testmain {
        width: 1141px;
        margin: 0 auto;
        overflow: hidden;
        margin-bottom: 20px;
    }

    .test.container .col-xs-70 {
        width: 70%;
        float: left;
        padding: 50px;
        text-align: left;
    }

    .test.container .col-xs-70 p {
        font-size: 18px;
        font-weight: 400;
        text-align: left;
    }

    .test.container .col-xs-30 {
        width: 30%;
        float: left;
    }

    .test.container .col-xs-70 img {
        max-width: 700px;
        max-height: 182px;
        margin-left: 45px;
        margin-bottom: 35px;
    }

    .test.container .col-xs-70 .choose div {
        line-height: 44px;
        margin-left: 40px;
    }

    .test.container .col-xs-70 .choose label {
        font-weight: 400
    }

    .test.container .col-xs-70 .pre {
        display: inline-block;
        width: 110px;
        border-radius: 5px;
        border: 1px solid #000;
        text-align: center;
        color: #000;
        font-size: 20px;
        line-height: 32px;
        margin: 50px 0 20px 40px;
        cursor: pointer;
        background: repeating-linear-gradient(130deg, #000, #000 2px, #fff 0, #fff 5px);
    }

    .test.container .col-xs-70 .next {
        display: inline-block;
        width: 110px;
        border-radius: 5px;
        border: 1px solid #000;
        text-align: center;
        color: #000;
        font-size: 20px;
        line-height: 32px;
        margin: 50px 0 20px 40px;
        cursor: pointer;
        background: repeating-linear-gradient(130deg, #000, #000 2px, #3CC97A 0, #3CC97A 5px);
    }

    .choose div {
        background: repeating-linear-gradient(130deg, #000, #000 2px, #fff 0, #fff 5px);
        border-radius: 12px;
        border: 1px solid #000;
        display: inline-block;
        margin-top: 20px;
        min-width: 320px;

    }

    #question p {
        display: inline-block;
        padding: 57px 113px 41px 52px;
        max-width: 550px;
        font-size: 20px;
        min-height: 160px;
        background-image: url(./img/rl.png);
        background-size: 100% 100%;
    }

    .choose label {
        background: #fff;
        width: 100%;
        height: 100%;
        border-radius: 5px;
        border: 1px solid #000;
        position: relative;
        top: -5px;
        padding: 0 10px;
        margin: 0;
        font-size: 20px;

    }

    .test.container .col-xs-70 .num {
        display: inline-block;
        width: 36px;
        height: 32px;
        border: 1px solid #dfdfdf;
        font-size: 12px;
        line-height: 34px;
        text-align: center;
        margin-left: -1px;
        margin-top: -1px;
        cursor: pointer;
    }

    .test.container .col-xs-70 .questionnum {
        font-size: 0
    }

    .test.container .col-xs-70 .num.active {
        background: #169bd5;
        color: #fff;
    }

    .test.container .col-xs-30 .top {
        width: 308px;
        height: 450px;
        margin-top: 40px;
        padding-top: 15px;
        padding-left: 15px;
        background-image: url(./img/zhengjian.png);
        background-size: 100% 100%;
        background-position: bottom;
    }

    .test.container .col-xs-30 .bottom {
        width: 271px;
        height: 98px;
        border: 1px solid #999999;
        margin-top: 30px;
        margin-bottom: 30px;
    }

    .test.container .col-xs-30 .top .title {
        color: #999999;
        font-size: 13px;
        text-align: left;
        margin-top: 45px;
    }

    .test.container .col-xs-30 .top img {
        width: 122px;
        height: 162px;
        margin-left: -15px;
        margin-top: 20px
    }

    .test.container .col-xs-30 .info {
        text-align: left;
        line-height: 38px;
        font-size: 16px;
        padding-top: 20px;
        padding-left: 20px
    }

    .test.container .col-xs-30 .bottom .text {
        font-size: 20px;
        position: relative;
        top: -15px;
        background: #fff;
        display: inline;
    }

    .test.container .col-xs-30 .bottom .time {
        font-size: 28px;
        color: #FF0000;
    }

    .test .submitTest {
        width: 110px;
        border-radius: 5px;
        border: 1px solid #000;
        text-align: center;
        color: #000;
        font-size: 20px;
        line-height: 32px;
        cursor: pointer;
        background: repeating-linear-gradient(130deg, #000, #000 2px, #169bd5 0, #169bd5 5px);
        float: right;
        margin-top: 50px;
        margin-right: 70px;
    }

    .error {
        background: #ff0000 !important;
        color: #fff !important;
    }

    html {
        height: 100% !important;
    }

    body {
        position: relative !important;
        min-height: 100% !important;
        box-sizing: border-box !important;
        padding-bottom: 165px !important;
        /* .footer 的高度，为 footer 占位 */
    }

    .footer {
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 115px !important;
    }
</style>

<body>
    <!-- 头部导航 -->
    <div class="head">
        <div style="background: #006633">
            <div class="container">
                <div style="line-height: 30px;color:#fff;position: absolute;font-size:12px;">山东省足球运动协会欢迎您！</div>
                <div class="do">
                    <div class="does1" style="display: block;">
                        <a href="http://newtest.sdfa.org.cn/footballAssociation/zuxie/login.html"><span>登录</span></a>
                        |
                        <a href="http://newtest.sdfa.org.cn/footballAssociation/zuxie/register.html"><span>注册</span></a>
                    </div>
                    <div class="does2" style="display:none">
                        <span>欢迎<span id="telphone" style="margin:0"></span></span>
                        |
                        <span><a href="http://newtest.sdfa.org.cn/footballAssociation/zuxie/personal.html"
                                id="nickname">个人中心</a></span>
                        |
                        <span class="logout" style="cursor: pointer;">退出</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="head-choose">
            <div class="container">
                <img src="http://newtest.sdfa.org.cn/webfile//public/headicon.png"
                    style="position: absolute;top: 15px;">
                <a href="http://newtest.sdfa.org.cn/">
                    <div class="headtext">
                        <div class="headtext1">山东省足球运动协会</div>
                        <div class="headtext2">SHANDONG FOOTBALL ASSOCIATION</div>
                    </div>
                </a>
                <div style="display:inline-block;margin-left:302px">
                    <div class="choosea">
                        <a href="http://newtest.sdfa.org.cn/index.html?id=67">
                            <div>首页</div>
                        </a>
                        <div class="choosea-2">
                        </div>
                    </div>
                    <div class="choosea">
                        <a href="http://newtest.sdfa.org.cn/notice.html?id=68">
                            <div>通知公告</div>
                        </a>
                        <div class="choosea-2">
                            <a href="http://newtest.sdfa.org.cn/notice.html?id=68&amp;item=1">
                                <div>公告规程</div>
                            </a>
                            <a href="http://newtest.sdfa.org.cn/notice.html?id=68&amp;item=2">
                                <div>政策法规</div>
                            </a>
                        </div>
                    </div>
                    <div class="choosea">
                        <a href="javascript:void(0);">
                            <div>足球专区</div>
                        </a>
                        <div class="choosea-2">
                            <a href="http://newtest.sdfa.org.cn/soccernotice.html?id=70">
                                <div>女足专区</div>
                            </a>
                            <a href="http://newtest.sdfa.org.cn/prefecture.html?id=84&item=2&child=1">
                                <div>青少年足球</div>
                            </a>
                            <a href="http://newtest.sdfa.org.cn/soccernotice.html?id=72">
                                <div>社会足球</div>
                            </a>
                        </div>
                    </div>
                    <div class="choosea">
                        <a href="http://newtest.sdfa.org.cn/otherplace.html?id=87">
                            <div>各地足协</div>
                        </a>
                        <div class="choosea-2">
                        </div>
                    </div>
                    <div class="choosea">
                        <a href="http://newtest.sdfa.org.cn/shopping/index.htm" target="_blank">
                            <div>商城</div>
                        </a>
                        <div class="choosea-2" target="_blank">
                        </div>
                    </div>
                    <div class="choosea">
                        <a href="http://newtest.sdfa.org.cn/aboutus.html?id=77">
                            <div>关于我们</div>
                        </a>
                        <div class="choosea-2">
                        </div>
                    </div>
                </div>
                <form action="result.html" method="post">
                    <div class="input-group">
                        <input type="text" name="word" value="" autocomplete="off" class="form-control"
                            placeholder="请输入您要搜索的内容">
                        <span class="glyphicon glyphicon-search" onclick="$('.head form').submit()"></span>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- 当前位置 -->
    <div class="thislocation container">
        <span>当前位置：</span>
        <span><a href="http://newtest.sdfa.org.cn/prefecture.html?id=84&item=2&child=1">青少年足球</a></span>
        <span> > 足球等级评定考核考试</span>
    </div>
    <!-- 考试 -->
    <div class="test container">
        <p><img src="./img/111.png" alt=""></p>
        <div class="testmain">
            <div class="col-xs-70">
                <div id="question">
                    <script type="text/html" id="showQuestion">
                        {{if questionText.isMultipleSelect==2}}
                        <p>{{questionSort}}、 {{questionText.content}}（单选题）</p>
                        <img src="{{questionText.url}}" alt="">
                        <div class="choose" id="no{{questionText.id}}">
                            {{if questionText.wordOrImg==1}}
                            <div><label><input type="radio" name="Options" id="A" value="{{questionText.id}}">
                                    A、{{questionText.optionList[0].content}}</label></div>
                            <div><label><input type="radio" name="Options" id="B" value="{{questionText.id}}">
                                    B、{{questionText.optionList[1].content}}</label></div>

                            {{if questionText.optionList[2].content}}
                            <div><label><input type="radio" name="Options" id="C" value="{{questionText.id}}">
                                    C、{{questionText.optionList[2].content}}</label></div>
                            {{/if}}
                            {{if questionText.optionList[3].content}}
                            <div><label><input type="radio" name="Options" id="D" value="{{questionText.id}}">
                                    D、{{questionText.optionList[3].content}}</label></div>
                        </div>
                        {{/if}}
                        {{/if}}
                        {{if questionText.wordOrImg==2}}
                        <div><label><input type="radio" name="Options" id="A" value="{{questionText.id}}">
                                <img src="{{questionText.optionList[0].content}}" alt=""></label></div>
                        <div><label><input type="radio" name="Options" id="B" value="{{questionText.id}}">
                                <img src="{{questionText.optionList[1].content}}" alt=""></label></div>

                        {{if questionText.optionList[2].content}}
                        <div><label><input type="radio" name="Options" id="C" value="{{questionText.id}}">
                                <img src="{{questionText.optionList[2].content}}" alt=""></label></div>
                        {{/if}}
                        {{if questionText.optionList[3].content}}
                        <div><label><input type="radio" name="Options" id="D" value="{{questionText.id}}">
                                <img src="{{questionText.optionList[3].content}}" alt=""></label></div>
                        </div>
                        {{/if}}
                        {{/if}}
                        {{/if}}
                        {{if questionText.isMultipleSelect==1}}
                        <p>{{questionSort}}、 {{questionText.content}}（多选题）</p>
                        <img src="{{questionText.url}}" alt="">
                        <div class="choose" id="no{{questionText.id}}">
                            {{if questionText.wordOrImg==1}}
                            <div><label><input type="checkbox" name="Options" id="A" value="{{questionText.id}}">
                                    A、{{questionText.optionList[0].content}}</label></div>
                            <div><label><input type="checkbox" name="Options" id="B" value="{{questionText.id}}">
                                    B、{{questionText.optionList[1].content}}</label></div>

                            {{if questionText.optionList[2].content}}
                            <div><label><input type="checkbox" name="Options" id="C" value="{{questionText.id}}">
                                    C、{{questionText.optionList[2].content}}</label></div>
                            {{/if}}
                            {{if questionText.optionList[3].content}}
                            <div><label><input type="checkbox" name="Options" id="D" value="{{questionText.id}}">
                                    D、{{questionText.optionList[3].content}}</label></div>
                        </div>
                        {{/if}}
                        {{/if}}
                        {{if questionText.wordOrImg==2}}
                        <div><label><input type="checkbox" name="Options" id="A" value="{{questionText.id}}">
                                <img src="{{questionText.optionList[0].content}}" alt=""></label></div>
                        <div><label><input type="checkbox" name="Options" id="B" value="{{questionText.id}}">
                                <img src="{{questionText.optionList[1].content}}" alt=""></label></div>

                        {{if questionText.optionList[2].content}}
                        <div><label><input type="checkbox" name="Options" id="C" value="{{questionText.id}}">
                                <img src="{{questionText.optionList[2].content}}" alt=""></label></div>
                        {{/if}}
                        {{if questionText.optionList[3].content}}
                        <div><label><input type="checkbox" name="Options" id="D" value="{{questionText.id}}">
                                <img src="{{questionText.optionList[3].content}}" alt=""></label></div>
                        </div>
                        {{/if}}
                        {{/if}}
                        {{/if}}
                    </script>
                </div>
                <div class="pre" onclick="pre()">
                    <div
                        style="background: #fff;display: inline-block;width: 110px;height: 32px;border-radius: 5px;border: 1px solid #000;position: relative;top: -3px;left: -1px;">
                        上一题</div>
                </div>
                <div class="next" onclick="next()">
                    <div
                        style="background: #3CC97A;display: inline-block;width: 110px;height: 32px;border-radius: 5px;border: 1px solid #000;position: relative;top: -3px;left: -1px;">
                        下一题</div>
                </div>
                <div class="submitTest" onclick="submitTest()">
                    <div
                        style="background: #169bd5;display: inline-block;width: 110px;height: 32px;border-radius: 5px;border: 1px solid #000;position: relative;top: -3px;left: -1px;">
                        提交考试</div>
                </div>
                <hr style="border-top: 1px solid #ccc;margin: 20px 65px 20px 15px" />

                <div
                    style="padding: 15px;padding-right: 30px;border: 2px solid #9FCCB3;border-radius: 21px;display: inline-block;font-size: 0;position: relative;">
                    <img src="./img/1.png" alt="" style="position: absolute;bottom: -4px;right: -2px;margin: 0;">
                    <img src="./img/2.png" alt="" style="position: absolute;left: -2px;top: -4px;margin: 0;">
                    <img src="./img/zuqiu.png" alt="" style="position: absolute;margin: 0;right: 5px;bottom: 5px;">
                    <div class="questionnum" id="questionnum" style="display: inline-block;">
                        <script type="text/html" id="testnum">
                            <% for(var i = 0; i < testnum; i++){ %>
                            <span class="num" onclick="changeQueByNum(this),abc(this)">{{i+1}}</span>
                            <% } %>
                        </script>
                    </div>
                </div>

            </div>
            <div class="col-xs-30">
                <div class="top" id="info">
                    <script type="text/html" id="userInfo">
                        <div class="title">
                            <span>当前考试：</span>
                            <span>球员考试></span>
                            <span>{{level}}级球员</span>
                        </div>
                        <img src="{{headImg}}" alt="">

                        <div class="info">

                            <div>姓名：{{name}}</div>
                            <div>准考编号：{{num}}</div>
                            <div>考试题数：{{testnum}}</div>
                            <div>考试时间：{{testtime}}分钟</div>

                        </div>
                    </script>
                </div>
                <div class="bottom">
                    <div class="text">剩余时间</div>
                    <div class="time">
                        <span id="hour_show">00</span>：<span id="minute_show">00</span>：<span id="second_show">00</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 底部 -->
    <div class="footer" style="min-width: 100%;">
        <div>
            版权所有：山东省足球运动协会官方网站
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            ICP经营许可证：鲁ICP备15020327号
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            山东乐体网络科技有限公司
        </div>
    </div>
</body>
<script src="./js/jquery.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/artTemplate.js"></script>
<script src="./js/layer/layer.js"></script>
<script>
    var examinationList = [] //题目保存数组
    var examinationListNum = 0 //题号
    var lastTestNum //最后一页题号
    var questionAnser = [] //答案集合
    var finishQuestion = [] //有答案的题号
    var isSupplementaryExamination //是否为补考
    var test1
    // 全局缓存global_nickName
    var global_nickName = sessionStorage.nickName;
    var global_userId = sessionStorage.userId;
    if (global_userId) {
        $('.do .does1').css('display', 'none')
        $('.do .does2').css('display', 'block')
    } else if (global_nickName == undefined || global_nickName == "") {
        $('.do .does1').css('display', 'block')
        $('.do .does2').css('display', 'none')
    }
    var global_tel = sessionStorage.tel;
    $("#telphone").text(global_tel)





    // 提示并开始考试 
    $.ajax({ //请求用户信息
        type: "POST",
        url: getRequestPrefix() + "/user/examination/examinationStart",
        dataType: "JSON",
        success: function (res) {
            if (res.msg == "您当前暂未登录，请登录后在操作") {
                layer.alert(res.msg, {
                    title: "提示",
                    cancel: function () {
                        window.location.href =
                            "http://newtest.sdfa.org.cn/footballAssociation/zuxie/login.html"
                    }
                }, function () {
                    window.location.href =
                        "http://newtest.sdfa.org.cn/footballAssociation/zuxie/login.html"
                });
                return false
            }
            isSupplementaryExamination = res.isSupplementaryExamination
            if (res.msg !== "0") {
                layer.alert(res.msg, {
                    title: "提示",
                    cancel: function () {
                        window.location.href =
                            "http://newtest.sdfa.org.cn/gradeaudit.html"
                    }
                }, function (params) {
                    window.location.href =
                        "http://newtest.sdfa.org.cn/gradeaudit.html"
                });
            } else {
                $("body").css("pointer-events", "none")
                $(".test").css("pointer-events", "all")
                if (isSupplementaryExamination == "1") {

                    examinationList = res.examinationList.clone(); // 克隆数组
                    showQuestion(); // 显示题
                    lastTestNum = res.examinationList.length; // 总题数
                    data = {
                        headImg: res.headPortraitUrl, //头像
                        level: res.level, //等级
                        name: res.name, //考生名字
                        num: res.examinationNo, //准考证号
                        testnum: res.examinationList.length, //总题数
                        testtime: res.time, //考试时间
                        isCheckBox: res.examinationList.isMultipleSelect //是否单选
                    };
                    var html = template('userInfo', data);
                    document.getElementById("info").innerHTML = html;
                    var html2 = template('testnum', data);
                    document.getElementById("questionnum").innerHTML = html2;
                    var intDiff = parseInt(data.testtime * 60); //倒计时总秒数量
                    timer(intDiff);


                } else if (isSupplementaryExamination == "2") {
                    examinationList = res.examinationList.clone(); // 克隆数组
                    showQuestion(); // 显示题
                    lastTestNum = res.examinationList.length; // 总题数
                    data = {
                        headImg: res.headPortraitUrl, //头像
                        level: res.level, //等级
                        name: res.name, //考生名字
                        num: res.examinationNo, //准考证号
                        testnum: res.examinationList.length, //总题数
                        testtime: res.time, //考试时间
                        isCheckBox: res.examinationList.isMultipleSelect //是否单选
                    };
                    var html = template('userInfo', data);
                    document.getElementById("info").innerHTML = html;
                    var html2 = template('testnum', data);
                    document.getElementById("questionnum").innerHTML = html2;
                    var intDiff = parseInt(data.testtime * 60); //倒计时总秒数量
                    timer(intDiff);
                    layer.close(index)
                }

            }

        }
    });

    function timeOut(e) { //时间耗尽的方法
        $(".time").html("<span>" + "时间到，自动提交" + "</span>");
        clearTimeout(e);
        submitTest()
    }

    function changeQueByNum(e) { //点击页码更换题目
        examinationListNum = $(e).index();
        saveAnswer();
        showQuestion();
        showchecked()
    }

    // 数组拷贝方法
    Array.prototype.clone = function () {
        var a = [];
        for (var i = 0, l = this.length; i < l; i++) {
            a.push(this[i]);
        }
        return a;
    };

    // 上一题
    function pre() {
        if (examinationListNum == 0) {
            layer.alert("已经是第一道题", {
                title: "提示"
            });
            return false
        } else {
            examinationListNum = examinationListNum - 1;
            saveAnswer();
            showQuestion();
            showchecked()
        }
    };

    // 下一题
    function next() {
        if (examinationListNum == lastTestNum - 1) {
            layer.alert("已经是最后一道题", {
                title: "提示"
            });
            return false
        } else {
            examinationListNum = examinationListNum + 1;
            saveAnswer();
            showQuestion();
            showchecked()
        }
    };

    function timer(intDiff) { //倒计时方法
        test1 = setInterval(function () {
            var hour, minute, second; //时间默认值        
            if (intDiff >= 0) {
                hour = Math.floor(intDiff / (60 * 60));
                minute = Math.floor(intDiff / 60) - (hour * 60);
                second = Math.floor(intDiff) - (hour * 60 * 60) - (
                    minute * 60);
            }
            if (minute <= 9) minute = '0' + minute;
            if (second <= 9) second = '0' + second;
            $('#minute_show').html('<s></s>' + minute);
            $('#second_show').html('<s></s>' + second);
            intDiff--;
            if (minute <= 0 && second == 0) timeOut(test1);
        }, 1000);
    };

    // 显示题目
    function showQuestion() {
        showActive()
        data = {
            questionText: examinationList[examinationListNum],
            questionSort: examinationListNum + 1
        }
        var html = template('showQuestion', data);
        document.getElementById("question").innerHTML = html;
        console.log(data)
    }

    // 保存题号答案
    function saveAnswer() {
        if ($(".choose input:not(:checked)").length !== $(".choose input").length) { //判断是否为空题
            var tihao = Number($(".choose input:checked").val());
            var xuanxiang = "";
            for (var i = 0; i < $(".choose input:checked").length; i++) {
                xuanxiang += $(".choose input:checked").eq(i).attr("id");
            }
            var answer = {
                examinationId: tihao,
                answer: xuanxiang
            };

            if (answer.examinationId !== undefined) {
                if (questionAnser.length == 0) {
                    questionAnser.push(answer);
                } else if (findIndexByKey(questionAnser, "examinationId", answer.examinationId) !== null) {
                    questionAnser.forEach(function (e) {
                        if (e.examinationId == answer.examinationId) {
                            e.answer = answer.answer
                        }
                    })
                } else {
                    questionAnser.push(answer);

                }
            }
        } else {
            var tihao = Number($(".choose input").eq(0).val());
            var xuanxiang = "";
            var answer = {
                examinationId: tihao,
                answer: xuanxiang
            };

            if (answer.examinationId !== undefined) {
                if (questionAnser.length == 0) {
                    questionAnser.push(answer);
                } else if (findIndexByKey(questionAnser, "examinationId", answer.examinationId) !== null) {
                    questionAnser.forEach(function (e) {
                        if (e.examinationId == answer.examinationId) {
                            e.answer = answer.answer
                        }
                    })
                } else {
                    questionAnser.push(answer);

                }
            }
        }

    };
    //删除数组特定元素
    Array.prototype.remove = function (val) {
        var index = this.indexOf(val);
        if (index > -1) {
            this.splice(index, 1);
        }
    };

    // 查询数组方法
    function findIndexByKey(array, key, value) {
        for (var i = 0; i < array.length; i++) {
            if (array[i][key] == value) {
                return i;
            }
        }
        return null;
    }

    // 已做未做题
    function showActive() {
        questionAnser.forEach(function (e) {
            if (e.answer !== "") {
                if (!finishQuestion.includes(findIndexByKey(examinationList, "id", e.examinationId))) {
                    finishQuestion.push(findIndexByKey(examinationList, "id", e.examinationId))
                }
            } else {
                finishQuestion.remove(findIndexByKey(examinationList, "id", e.examinationId))
            }
        })
        console.log(finishQuestion)
        $("#questionnum span").removeClass("active")
        for (var i = 0; i < finishQuestion.length; i++) {
            $("#questionnum span").eq(finishQuestion[i]).addClass("active")
        }
    }

    // 保存选项
    function showchecked() {
        console.log(JSON.stringify(questionAnser))
        questionAnser.forEach(function (e) {
            for (var i = 0; i < e.answer.length; i++) {
                $("#no" + e.examinationId + " " + "#" + e.answer.substr(i, 1)).prop("checked", "checked")
            }
        })
    }

    // 提交考试
    function submitTest() {
        saveAnswer()
        var total = [];
        var other = [];
        for (var i = 0; i < examinationList.length; i++) {
            total.push(examinationList[i].id)
        }
        for (var i = 0; i < questionAnser.length; i++) {
            other.push(questionAnser[i].examinationId)
        }
        console.log(diff(total, other).length)
        if (questionAnser.length !== examinationList.length) {
            for (var i = 0; i < diff(total, other).length; i++) {
                questionAnser.push({
                    examinationId: diff(total, other)[i],
                    answer: ""
                })
            }
        }
        console.log(JSON.stringify(questionAnser))
        $.ajax({ //请求用户信息
            type: "POST", //发送考试结果
            url: getRequestPrefix() + "/user/examination/saveAnswer",
            dataType: "JSON",
            data: {
                answerList: JSON.stringify(questionAnser),
                isSupplementaryExamination: isSupplementaryExamination
            },
            success: function (res) {
                if (res.msg == "您当前暂未登录，请登录后在操作") {
                    layer.alert(res.msg, {
                        title: "提示",
                        cancel: function () {
                            window.location.href =
                                "http://newtest.sdfa.org.cn/footballAssociation/zuxie/login.html"
                        }
                    }, function () {
                        window.location.href =
                            "http://newtest.sdfa.org.cn/footballAssociation/zuxie/login.html"
                    });
                    return false
                }
                clearInterval(test1)
                if (res.msg == "0") {
                    if (res.iswhkAdopt == "通过") {
                        layer.alert("您已成功通过考试", {
                            title: "提示",
                            cancel: function () {
                                window.location.href =
                                    "http://newtest.sdfa.org.cn/prefecture.html?id=84&item=2&child=1"
                            }
                        }, function (params) {
                            window.location.href =
                                "http://newtest.sdfa.org.cn/prefecture.html?id=84&item=2&child=1"
                        });
                    } else if (res.iswhkAdopt == "未通过" && isSupplementaryExamination == 1) {
                        layer.alert("您的成绩为" + res.score + "分，未通过考试，点击确定进行补考", {
                            title: "提示",
                            cancel: function () {
                                window.location.reload()
                            }
                        }, function () {
                            window.location.reload()
                        });
                    } else {
                        layer.alert("您未通过考试", {
                            title: "提示",
                            cancel: function () {
                                window.location.href =
                                    "http://newtest.sdfa.org.cn/prefecture.html?id=84&item=2&child=1"
                            }
                        }, function (params) {
                            window.location.href =
                                "http://newtest.sdfa.org.cn/prefecture.html?id=84&item=2&child=1"
                        });
                    }
                } else {
                    layer.alert(res.msg, {
                        title: "提示",
                        cancel: function (index) {
                            layer.close(index);
                        }
                    })
                }
            }
        });
    }

    // 比较数组不同
    function diff(arr1, arr2) {
        var a = [];
        var b = [];

        for (var i = 0; i < arr2.length; i++) {
            a[arr2[i]] = true;
        }

        for (var i = 0; i < arr1.length; i++) {
            if (!a[arr1[i]]) {
                b.push(arr1[i]);
            }
        }
        return b
    }

    function abc(e) {
        console.log($(e))
    }


    function getRequestPrefix() {
        // return "http://192.168.0.160:8083/footballAssociation"
        // 获取网络协议
        // 获取主机名+端口号
        var domainPort = window.location.host;
        // 获取发布项目的名称
        // 获取路径
        var url = window.location.pathname;
        var webApp = url.split('/')[1];
        // http://127.0.0.1/demo
        var urlPrefix = "http://" + domainPort + "/" + webApp;
        return urlPrefix;
    }
</script>

</html>